#ifndef BASE_TIME_H
#define BASE_TIME_H

#include "base_core.h"

float time_get(void);
void time_sleep(float dT);


//-----------------------------------------------------------------------------
// Clock
//-----------------------------------------------------------------------------


/**
 * \brief Clock structure.
 */
typedef struct
{
    /// \brief Absolute time reference.
    float timeAbsolute;
    /// \brief time when paused
    float timePause;
    float timeStarted;
    /// \brief Pause flag.
    int isPaused;
    int isStopped;

} Clock;

/**
 * \brief Create a new clock.
 * \return A paused clock set to 0.
 */
Clock* clock_new(void);

/**
 * \brief Free a clock.
 * \param t Clock to free
 */
void clock_delete(Clock *t);

/**
 * \brief Get time elapsed since clock creation.
 * \param t Clock
 * \return Delay in seconds.
 */
float clock_get(Clock *t);

/**
 * \brief Start a clock.
 * \param t Clock
 */
void clock_start(Clock *t);

/**
 * \brief Pause a clock.
 * \param t Clock
 */
void clock_pause(Clock *t);

/**
 * \brief Reset a clock to 0 and pause it.
 * \param t Clock
 */
void clock_reset(Clock *t);

#endif
